package com.weimei.conversionTreasure.viewModel;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.databinding.ObservableList;

import com.chad.library.BR;
import com.weimei.conversionTreasure.R;
import com.weimei.conversionTreasure.http.entity.DealerDetailBean;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.ItemViewModel;
import me.tatarka.bindingcollectionadapter2.ItemBinding;

public class TransactionItemVM extends ItemViewModel {

    public ObservableField<DealerDetailBean.DataDTO.TradeListDTO> entity  =new ObservableField<>();
    public ObservableList<TransactionItemChlidVM> observableList = new ObservableArrayList<>();
    public ItemBinding<TransactionItemChlidVM> itemBinding = ItemBinding.of(BR.viewModel, R.layout.item_trans_child);

    public TransactionItemVM(@NonNull BaseViewModel viewModel, DealerDetailBean.DataDTO.TradeListDTO bean) {
        super(viewModel);
        entity.set(bean);
        for (DealerDetailBean.DataDTO.TradeListDTO.TradeListDTOC childBean : bean.getTradeList()) {
            TransactionItemChlidVM itemChlidVM = new TransactionItemChlidVM(viewModel,childBean);
            observableList.add(itemChlidVM);
        }

    }
}
